﻿using System;
using System.Net;

namespace SCG.SolarVengeanceEngine.StarShips
{
    //base class for missiles
    public abstract class Missile : StarShip
    {
        //constructor
        public Missile(SVGame game, Player owner, int engines, int warheads, StarSystem origin)
            : base(game, owner, engines, warheads, origin)
        {
        }

        //Can target any StarSystem if they don't already have an order
        public override bool CanExecuteOrder(OrderType ot)
        {
            if (Order != null)
                return false;
            else
                return ot == OrderType.TargetStarSystem;
        }
        public override bool CanTargetStarSystem(StarSystem target, bool considerAlliance)
        {
            return true;
        }

        //basic handling for missile impacts
        protected override void TargetAdjacentStarSystem(StarSystem system)
        {
            //Report the attack to the host
            if (Game.Host != null)
                Game.Host.StarSystemAttacked(system, Owner);

            //Submit state change
            Game.SubmitStateChange(StateChange.AttackStarSystem, system, Owner); 

            //destroy the missile
            Game.DestroyStarShip(this);
        }
    }
}
